class Keploy < Formula
  desc "Testing Toolkit creates test-cases and data mocks from API calls, DB queries"
  homepage "https://keploy.io"
  url "https://github.com/keploy/keploy/archive/refs/tags/v2.10.12.tar.gz"
  sha256 "1a3e8098795359d22635501c9c19466a6b64bb2e6840bbf7131e8f09f64d0518"
  license "Apache-2.0"
  head "https://github.com/keploy/keploy.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "dbfc138aa3fd45a8e04d3c5f609b731076f4c04ca2d6d615baaab9e22c43cf36"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "dbfc138aa3fd45a8e04d3c5f609b731076f4c04ca2d6d615baaab9e22c43cf36"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "dbfc138aa3fd45a8e04d3c5f609b731076f4c04ca2d6d615baaab9e22c43cf36"
    sha256 cellar: :any_skip_relocation, sonoma:        "719fa88e30bf58e3ef8c0e61a75babac1465b750c42e064dd38376a065c9a9de"
    sha256 cellar: :any_skip_relocation, ventura:       "719fa88e30bf58e3ef8c0e61a75babac1465b750c42e064dd38376a065c9a9de"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "ddd32ac11575760bd3110104ae7f70c9f08d3ff3c7f208ba1aae250d876fadde"
  end

  depends_on "go" => :build

  def install
    system "go", "build", *std_go_args(ldflags: "-s -w -X main.version=#{version}")
  end

  test do
    system bin/"keploy", "config", "--generate", "--path", testpath
    assert_match "# Generated by Keploy", (testpath/"keploy.yml").read

    output = shell_output("#{bin}/keploy templatize --path #{testpath}")
    assert_match "No test sets found to templatize", output

    assert_match version.to_s, shell_output("#{bin}/keploy --version")
  end
end
